
import time

#定义一个打印 函数执行时间 的装饰器
def metric(fn):
    def interNalMet(*args, **kwargs):
        start_time = time.time()
        result = fn(*args, **kwargs)    #考虑原函数可能带有返回值！
        end_time = time.time()
        print('函数：{} 执行耗时：{:.10f}s'.format(fn.__name__,end_time - start_time))
        return result #需要把原函数结果返回
    return interNalMet

@metric
def tryModule():
    try:
        print('try ...开始...')
        a = 100 / 0
        print('result:', a)
    except  ValueError as e:
        print('ValueError', e)
    except ZeroDivisionError as e:
        print('ZeroDivisionError', e)
    else:
        print('unkown error!')
    finally:
        print('不好意思，出错了')

@metric
def countModule(a,b):
    return a+b

tryModule()
print(countModule(15646,5263456))